package com.hue.netty.day01.unpooled;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

/*
    Unpooled是netty提供的专门操作缓冲区的工具类
 */
public class Test {
    public static void main(String[] args) {
        //在netty的byteBuf中维护了readerIndex 和 writerIndex 在读取时不需要使用flip()切换
        ByteBuf buf = Unpooled.buffer(10);
        for (int i = 0; i < buf.capacity(); i++) {
            buf.writeByte(i);
        }
        for (int i = 0; i < buf.capacity(); i++) {
            System.out.println(buf.readByte());
        }
    }
}
